widgetpaintable: Clear an idle in dispose
authorMatthias Clasen <mclasen@redhat.com>
Fri, 7 Aug 2020 00:01:26 +0000 (20:01 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 7 Aug 2020 00:02:33 +0000 (20:02 -0400)
We were not removing the pending_update idle
in dispose, which is at least suspicious, if
not deadly. Move the idle cleanup code into
unset_widget(), which we are already calling
in dispose().

gtk/gtkwidgetpaintable.c

index a2d6a0cc22fe061bdb2d81d011c58da91a9454f4..1ed017db9e87b814f50d6a1067e7c3e61120d804 100644 (file)
@@ -201,6 +201,13 @@ gtk_widget_paintable_unset_widget (GtkWidgetPaintable *self)
                                                    self);
 
   self->widget = NULL;
+
+  g_clear_object (&self->pending_image);
+  if (self->pending_update_cb)
+    {
+      g_source_remove (self->pending_update_cb);
+      self->pending_update_cb = 0;
+    }
 }
 
 static void
@@ -332,19 +339,10 @@ gtk_widget_paintable_set_widget (GtkWidgetPaintable *self,
   self->widget = widget;
 
   if (widget)
-    {
-      widget->priv->paintables = g_slist_prepend (widget->priv->paintables,
-                                                  self);
-    }
+    widget->priv->paintables = g_slist_prepend (widget->priv->paintables, self);
 
   g_object_unref (self->current_image);
   self->current_image = gtk_widget_paintable_snapshot_widget (self);
-  g_clear_object (&self->pending_image);
-  if (self->pending_update_cb)
-    {
-      g_source_remove (self->pending_update_cb);
-      self->pending_update_cb = 0;
-    }
 
   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_WIDGET]);
   gdk_paintable_invalidate_size (GDK_PAINTABLE (self));